package vn.edu.uit.chemistry.model;

import vn.edu.uit.chemistry.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ProgressBar;
import android.widget.TextView;

public class FakeGameAdapter extends BaseAdapter {
	
	Context ctx;
	LayoutInflater mInflater;
	String[] nhoms = {"1", "2"};
	int[] xuly = {1, 0};

	public FakeGameAdapter(Context _ctx) {
		this.ctx = _ctx;
		mInflater = LayoutInflater.from(_ctx);
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return nhoms.length;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public class GameHolder {
		TextView tvNhom;
		TextView tvDangXuLy;
		TextView tvHoanTat;
		ProgressBar prPercent;
	}

	public View getView(int pos, View v, ViewGroup arg2) {
		GameHolder holder;
		if (v == null) {
			v = mInflater.inflate(R.layout.row_game, null);
			holder = new GameHolder();
			holder.prPercent = (ProgressBar) v.findViewById(R.id.prPercent);
			holder.tvNhom = (TextView) v.findViewById(R.id.tvNhom);
			holder.tvDangXuLy = (TextView) v.findViewById(R.id.tvPercent);
			holder.tvHoanTat = (TextView) v.findViewById(R.id.tvFinish);

			v.setTag(holder);
		} else {
			holder = (GameHolder) v.getTag();
		}
		
		holder.tvNhom.setText("Nhóm số: " + nhoms[pos]);
		
		if (xuly[pos] == 1) {
			holder.prPercent.setVisibility(View.VISIBLE);
			holder.tvDangXuLy.setVisibility(View.VISIBLE);
			holder.tvHoanTat.setVisibility(View.GONE);
		} else {
			holder.prPercent.setVisibility(View.GONE);
			holder.tvDangXuLy.setVisibility(View.GONE);
			holder.tvHoanTat.setVisibility(View.VISIBLE);
		}
		
		return v;
	}
	
}
